home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000078_icon-group-sender _Tue Apr 5 07:32:34 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 5 Apr 1994 09:01:18 MST
  2. Via: uk.ac.edinburgh.festival; Tue, 5 Apr 1994 15:31:10 +0100
  3. Date: 05 Apr 94 15:30:59 BST
  4. From: R J Hare <rjhare@festival.ed.ac.uk>
  5. Subject: 2-darrays
  6. To: icon-group@cs.arizona.edu
  7. Organisation: Edinburgh University Computing Service
  8. Message-Id: <9404051531.aa04767@uk.ac.ed.festival>
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. The method on p52 of the the 1st edition of the Icon book (all I have to hand
  13. at the moment) uses lists of lists:
  14.  
  15. procedure array(i,j,x)
  16. a:=list(i,0)
  17. k:=0
  18. while a[k +:= 1] := list(j,x)
  19. return a
  20. end
  21.  
  22. I think I'd do it like this (in fact I have done and it seems to work) - to me
  23. this is easier to read than the first version:
  24.  
  25. procedure array(i,j,x)
  26. a:=list(i)
  27. every !a=list(j,x)
  28. return a
  29. end
  30.  
  31. So:
  32.  
  33. shogiboard:=array(9,9," ")
  34.  
  35. would return an empty 9x9 board.
  36.  
  37. You refer to eleents of the array as a[i][j] - later versions of Icon allow
  38. a[i,j].
  39.  
  40. Roger Hare.
  41.